package com.darren.framework.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * ResponseBean 响应对象
 * @Author: 周金涛
 * @Date: 2019/10/12 10:04
 */
@ApiModel(value = "响应对象")
public class ResponseBean {

    /**
     * 响应状态回值码
     */
    @ApiModelProperty(value = "响应状态码")
    private Integer code;

    /** 返回信息 */
    @ApiModelProperty(value = "响应消息")
    private String message;

    /** 返回的数据 */
    @ApiModelProperty(value = "响应数据")
    private Object data;

    public ResponseBean(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResponseBean(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
    /**
     * 成功返回 不带数据
     */
    public static ResponseBean isOk(){
        return ResponseBean.isOk(null);
    }

    /**
     * 成功返回 带数据
     * @param message 消息
     */
    public static ResponseBean isOk(String message){
        return new ResponseBean(ResponseCode.OK,message,null);
    }

    /**
     * 成功返回 带数据
     * @param message 消息
     * @param data 数据
     */
    public static ResponseBean isOk(String message,Object data){
        return new ResponseBean(ResponseCode.OK,message,data);
    }

    /**
     * 成功返回 带数据
     * @param data 数据
     */
    public static ResponseBean isOk(Object data){
        return new ResponseBean(ResponseCode.OK,"Ok",data);
    }

    /**
     * 警告
     * @param message
     * @return
     */
    public static ResponseBean isWarn(String message){
        return new ResponseBean(ResponseCode.WARN,message,null);
    }

    /**
     * 失败返回
     * @param responseCode  错误码
     * @param message       错误信息
     * @return
     */
    public static ResponseBean isError(Integer responseCode,String message){
        return new ResponseBean(responseCode,message);
    }

    /**
     * 失败返回
     * @param message 错误信息
     */
    public static ResponseBean isError(String message){
        return new ResponseBean(ResponseCode.ERROR,message,null);
    }


    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
